package com.qzsoft.system.modules.zhjdsysdept.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.validator.constraints.Length;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qzsoft.jeemis.common.validator.group.AddGroup;
import com.qzsoft.jeemis.common.validator.group.UpdateGroup;
import com.qzsoft.system.modules.zhjdsysdept.group.SysBaseAddGroup;
import com.qzsoft.system.modules.zhjdsysdept.group.SysBaseUpdateGroup;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @ClassName ZhjdSysDeptEntity
 * @Description 机构管理
 * @author linhuawei
 * @since 2021-12-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@TableName("sys_dept")
public class ZhjdSysDeptEntity {

    /**
     * 主键
     */
    @NotBlank(groups = UpdateGroup.class, message = "机构不可为空")
    @TableId(type = IdType.ASSIGN_UUID)
    private String pkid;

    /**
     * id步长3唯一
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String id;

    /**
     * 上级ID
     */
    @NotBlank(groups = SysBaseAddGroup.class, message = "所属机构不可为空")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String pid;

    /**
     * 上级ID
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String pids;

    /**
     * 机构类型
     */
    @NotBlank(groups = { AddGroup.class, UpdateGroup.class }, message = "机构类型不可为空")
    private String type;

    /**
     * 排序默认和id一致为了统一排序方便
     */
    private String sort;

//    /**
//     * 第三方名称
//     */
//    private String nickCode;

    /**
     * 简拼
     */
    private String spell;

    /**
     * 是否叶子节点
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Boolean hasLeaf;

    /**
     * 机构名称
     */
    @NotBlank(groups = { AddGroup.class, UpdateGroup.class }, message = "机构名称不可为空")
    @Length(groups = { AddGroup.class, UpdateGroup.class }, max = 20, message = "机构名称不可超过{max}个字")
    private String name;

    /**
     * 备注信息
     */
    @Length(groups = { AddGroup.class, UpdateGroup.class }, max = 200, message = "备注信息不可超过{max}位")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String info;

    /**
     * 机构编码
     */
    @NotBlank(groups = SysBaseAddGroup.class, message = "基地编码不可为空")
    @Pattern(groups = SysBaseAddGroup.class, regexp = "[0-9]{2}", message = "基地编码格式错误")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String code;

    /**
     * 序号
     */
    @Max(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, value = 65535, message = "显示序号错误")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Integer serial;

    /**
     * 负责人
     */
    @Length(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, max = 20, message = "负责人姓名不可超过{max}位")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String person;

    /**
     * 负责人电话
     */
    @Length(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, max = 11, message = "负责人电话不可超过{max}位")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String personTel;

    /**
     * 投产时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private Date startTime;

    /**
     * 经度（基地）
     */
    @DecimalMax(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, value = "180", message = "经度不是有效数据")
    @DecimalMin(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, value = "-180", message = "经度不是有效数据")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private BigDecimal longitude;

    /**
     * 纬度（基地）
     */
    @DecimalMax(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, value = "90", message = "纬度不是有效数据")
    @DecimalMin(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, value = "-90", message = "纬度不是有效数据")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private BigDecimal latitude;

    /**
     * 状态（基地时有效）：0=筹备，1=投产，2=已改造
     */
    @Length(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, max = 1, message = "基地状态错误")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String state;

    @Length(groups = { SysBaseAddGroup.class, SysBaseUpdateGroup.class }, max = 200, message = "详情地址不可超过{max}位")
    private String address;

    /**
     * 创建者
     */
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private Long creator;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private Date createDate;

    /**
     * 修改者
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updater;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateDate;

}
